package com.aotain.nyx.util;

import java.util.HashSet;

import org.apache.log4j.Logger;

public class IPFilterSingleUtil {

//	public String filterIpSql ;
//	public String whiteIpSql;
//	public String dbJson ;
	public static IPFilterSingleUtil instance = null;
	public static IPFilterSingleUtil instance2 = null;
	public static IPFilterSingleUtil instance3 = null;
	public HashSet<String> IPSet = new HashSet<String>();
	public HashSet<String> WhiteIpSet = new HashSet<String>();
	public HashSet<String> AppTypeSet = new HashSet<String>();
	
	private IPFilterSingleUtil(String filterIpSql,String whiteIpSql,String dbJsonNYX){
		WhiteIpSet = IPFilterUtil.getWhiteIpSet(whiteIpSql, dbJsonNYX);
		IPSet = IPFilterUtil.getFilterIpSet(filterIpSql, dbJsonNYX);
		Logger.getLogger(getClass()).info("###IPFilter### IPSet=" + IPSet.toString() +"; WhiteIpSet=" + WhiteIpSet.toString()); 
//		System.out.println("$$$$$IPSingleFliter$$$$$$$");
	}
	
	private IPFilterSingleUtil(String appTypeSql,String dbJsonNYX) {
		
		AppTypeSet = IPFilterUtil.getAppTypeList(appTypeSql, dbJsonNYX);
	}

	public static IPFilterSingleUtil getInstance(String filterIpSql,String whiteIpSql,String dbJsonNYX) {

		if(instance==null) {
			synchronized(IPFilterSingleUtil.class){
				if(instance==null){
					instance = new IPFilterSingleUtil(filterIpSql, whiteIpSql, dbJsonNYX);
				}
			}
		}
		return instance;
	}

	public static IPFilterSingleUtil getInstance2(String appTypeSql,String dbJsonNYX) {

		if(instance2==null) {
			synchronized(IPFilterSingleUtil.class){
				if(instance2==null){
					instance2 = new IPFilterSingleUtil(appTypeSql, dbJsonNYX);
				}
			}
		}
		return instance2;
	}
	
	public static IPFilterSingleUtil getInstance3(String appTypeSql,String dbJsonNYX) {
		
		if(instance3==null) {
			synchronized(IPFilterSingleUtil.class){
				if(instance3==null){
					instance3 = new IPFilterSingleUtil(appTypeSql, dbJsonNYX);
				}
			}
		}
		return instance3;
	}
	
}
